<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>美兰数据文化馆与图书馆</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/formSelects-v4.css" media="all">
</head>
<style>
    /* 底部固定区域 */
    .layui-layout-admin .layui-footer {
        padding: 10px 0;
        text-align: center;
    }

    .layui-layout-admin .layui-footer {
        background-color: #fff;
    }

    .layui-form-label {
        width: 90px;
    }

    .layui-input-block {
        margin-left: 120px;
    }
</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" lay-filter="component-form-element">
                <input name="processlifetid" id="processlifetid" type="hidden">
                <div class="layui-row">
                    <fieldset class="layui-elem-field">
                        <legend>审批内容</legend>
                        <div class="layui-field-box">
                            <div class="layui-form-item">
                                <div class="layui-col-xs12">
                                    <div class="layui-col-xs6">
                                        <div class="layui-col-xs11">
                                            <div class="layui-inline"
                                                 style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                <label class="layui-form-label">主题</label>
                                                <div class="layui-input-block">
                                                    <input type="text"
                                                           class="layui-input"
                                                           style="border-left:0px;border-right: 0px;border-top: 0px;"
                                                           name="name" id="name" lay-verify="name" disabled>
                                                </div>
                                            </div>
                                        </div>
                                        <%--                                        <div class="layui-col-xs1">--%>
                                        <%--                                            <div class="layui-form-mid layui-word-aux"--%>
                                        <%--                                                 style="color: red !important;padding: 10px !important;">*--%>
                                        <%--                                            </div>--%>
                                        <%--                                        </div>--%>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-col-xs12">
                                    <div class="layui-col-xs3">
                                        <div class="layui-block"
                                             style="margin-bottom: 0px;margin-right: 0px;width: 83%">
                                            <label class="layui-form-label">批号</label>
                                            <div class="layui-input-block">
                                                <div class="layui-input-inline" style="width: 78px;margin:0px;">
                                                    <input type="text" autocomplete="off" class="layui-input"
                                                           value="460108GB" name="display" disabled
                                                           style="border-left:0px;border-right: 0px;border-top: 0px;">
                                                </div>
                                                <div class="layui-input-block" style="margin-left:78px;">
                                                    <input type="text" autocomplete="off" class="layui-input"
                                                           placeholder="" id="batchNumber" name="batchNumber"
                                                           style="padding-left:0px;border-left:0px;border-right: 0px;border-top: 0px;background-color:#fff;color:#6f6868; "
                                                           disabled>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                            <%--                            <table class="layui-hide" id="chemicalApplicationTable"--%>
                            <%--                                   lay-filter="chemicalApplicationTables"></table>--%>
                            <%--                            <div id="laypage"></div>--%>
                        </div>
                    </fieldset>
                </div>
                <div class="layui-row">
                    <div class="layui-form-item">
                        <fieldset class="layui-elem-field">
                            <legend>流程处理</legend>
                            <div class="layui-field-box">
                                <div class="layui-form">
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-inline"
                                                     style="margin-bottom: 0px;margin-right: 0px;width: 83%">
                                                    <label class="layui-form-label">紧急程度</label>
                                                    <div class="layui-input-block">
                                                        <input type="radio" name="urgent" value="紧急"
                                                               title="紧急" disabled>
                                                        <input type="radio" name="urgent" value="急"
                                                               title="急" disabled>
                                                        <input type="radio" name="urgent" value="一般"
                                                               title="一般" disabled>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-col-xs11">
                                                    <div class="layui-inline"
                                                         style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                        <label class="layui-form-label">审核部门:</label>
                                                        <div class="layui-input-block">
                                                            <select name="departmenttid" xm-select="departmenttid"
                                                                    xm-select-search=""
                                                                    xm-select-radio="" id="departmenttid"
                                                                    lay-verify="departmenttid" disabled="disabled">
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <%--                                                <div class="layui-col-xs1">--%>
                                                <%--                                                    <div class="layui-form-mid layui-word-aux"--%>
                                                <%--                                                         style="color: red !important;padding: 10px !important;">*--%>
                                                <%--                                                    </div>--%>
                                                <%--                                                </div>--%>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-col-xs11">
                                                    <div class="layui-inline"
                                                         style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                        <label class="layui-form-label">审核人员:</label>
                                                        <div class="layui-input-block">
                                                            <select name="usertid" xm-select="usertid"
                                                                    xm-select-search=""
                                                                    xm-select-radio="" id="usertid"
                                                                    lay-verify="usertid">
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="layui-col-xs1">
                                                    <div class="layui-form-mid layui-word-aux"
                                                         style="color: red !important;padding: 10px !important;">*
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs3">
                                                <div class="layui-inline"
                                                     style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                    <label class="layui-form-label">申请人:</label>
                                                    <div class="layui-input-block">
                                                        <input type="text"
                                                               class="layui-input" name="application"
                                                               style="border-left:0px;border-right: 0px;border-top: 0px;"
                                                               disabled id="startmanname">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <input type="hidden" name="one" value="one">
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs3">
                                                <div class="layui-inline"
                                                     style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                    <label class="layui-form-label">申请时间:</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" id="datetime"
                                                               autocomplete="off"
                                                               class="layui-input"
                                                               readonly=""
                                                               style="border-left:0px;border-right: 0px;border-top: 0px;"
                                                               lay-verify="datetime">
                                                    </div>
                                                </div>
                                            </div>
                                            <%--                                            <div class="layui-col-xs1">--%>
                                            <%--                                                <div class="layui-form-mid layui-word-aux"--%>
                                            <%--                                                     style="color: red !important;padding: 10px !important;">*--%>
                                            <%--                                                </div>--%>
                                            <%--                                            </div>--%>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-col-xs11">
                                                    <div class="layui-inline"
                                                         style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                        <label class="layui-form-label">审核意见:</label>
                                                        <div class="layui-input-block">
                                                            <textarea name="opinion" class="layui-textarea"
                                                                      id="opinion"></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-xs12">
                                            <div class="layui-col-xs6">
                                                <div class="layui-col-xs11">
                                                    <div class="layui-inline"
                                                         style="margin-bottom: 0px;margin-right: 0px;width: 100%">
                                                        <label class="layui-form-label">备注:</label>
                                                        <div class="layui-input-block">
                                                            <textarea name="remarks" class="layui-textarea"
                                                                      id="remarks"></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </div>
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-footer" style="left: 0;padding: 0px;">
                        <button class="layui-btn" lay-submit lay-filter="pushButton" id="pushButton">通过</button>
                        <button class="layui-btn layui-btn-danger" lay-submit lay-filter="fdsaf" id="fdsaf">驳回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="<%=request.getContextPath()%>/huazhi/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    function child(processlifetid) {
        layui.use(['form', 'laydate', 'formSelects', 'chemicalApplication'], function () {
            var $ = layui.$
                , table = layui.table
                , layer = layui.layer,
                form = layui.form,
                laydate = layui.laydate
                , formSelects = layui.formSelects;

            $("#processlifetid").val(processlifetid)

            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/rest/process/getProcessLifeByTid",
                dataType: "json",
                async: false,
                data: 'processlifetid=' + processlifetid,
                success: function (msg) {

                    $("#opinion").val(msg.opinion);
                    $("#remarks").val(msg.remarks);

                    $.ajax({
                        type: "post",
                        url: "<%=request.getContextPath()%>/rest/process/getProcessAllByTid",
                        dataType: "json",
                        async: false,
                        data: 'processalltid=' + msg.allprocesstid,
                        success: function (obj) {
                            $("#name").val(obj.title);
                            $("#batchNumber").val(obj.batchnumber);
                            $("#startmanname").val(obj.startmanname);
                            $("#datetime").val(obj.starttimestring);
                            form.val("component-form-element", obj)
                            form.render('radio');

                        }
                    })
                    $.ajax({
                        type: "post",
                        url: "<%=request.getContextPath()%>/rest/process/getExamineDep",
                        dataType: "json",
                        async: false,
                        data: 'processlisttid=' + msg.processlisttid,
                        success: function (obj) {
                            formSelects.data('departmenttid', 'local', {
                                arr: obj
                            });
                        }
                    })
                    $.ajax({
                        type: "post",
                        url: "<%=request.getContextPath()%>/rest/process/getExamineUser",
                        dataType: "json",
                        async: false,
                        data: 'processlisttid=' + msg.processlisttid + "&processlifetid=" + processlifetid,
                        success: function (obj) {
                            formSelects.data('usertid', 'local', {
                                arr: obj
                            });
                        }
                    })


                }
            })


            //第一种方法添加用户
            form.on('submit(pushButton)', function (data) {
                var field = data.field//当前容器的全部表单字段，名值对形式：{name: value}
                data.field.answer = "yes";

                var usertid = formSelects.value('usertid', 'valStr');
                if(usertid==""){
                    $("[name='usertid']").addClass("layui-form-danger");
                    $("[name='usertid']").focus();
                    layer.msg('请选择审核人员', {icon: 5, shift: 6});
                    return false;
                }

                var index = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.6});
                 $("#pushButton").addClass("layui-btn layui-btn-disabled").prop("disabled", true);
                $("#fdsaf").addClass("layui-btn layui-btn-disabled").prop("disabled", true);
                $.ajax({
                    type: "post",
                    url: "<%=request.getContextPath()%>/rest/process/agreeProcesslife",
                    data: field,
                    dataType: "json",
                    async: false,
                    success: function (obj) {
                        setTimeout(function () {
                            layer.close(index);
                            if (obj = true) {
                                layer.msg('审核成功');
                            } else {
                                layer.msg(obj.errorMsg);
                            }
                        }, 2000);
                        setTimeout(function () {
                            var indexs = parent.layer.getFrameIndex(window.name);//获取当前弹出层的层级
                            parent.layer.close(indexs);//关闭弹出层
//                        window.parent.location.reload();//刷新父页面
                        }, 4000);
                    }
                })
                return false;
            });

            //第一种方法添加用户
            form.on('submit(fdsaf)', function (data) {
                var field = data.field//当前容器的全部表单字段，名值对形式：{name: value}
                data.field.answer = "no";
                layer.confirm('确定是否驳回', {icon: 3, title: '提示信息', shade: 0.6}, function (index) {
                    layer.close(index);
                    var index = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.6});
                    setTimeout(function () {
                        $("#pushButton").addClass("layui-btn layui-btn-disabled").prop("disabled", true);
                        $("#fdsaf").addClass("layui-btn layui-btn-disabled").prop("disabled", true);
                        $.ajax({
                            type: "post",
                            url: "<%=request.getContextPath()%>/rest/process/agreeProcesslife",
                            data: field,
                            dataType: "json",
                            async: false,
                            success: function (obj) {
                                setTimeout(function () {
                                    layer.close(index);
                                    if (obj = true) {
                                        layer.msg('驳回成功');
                                    } else {
                                        layer.msg(obj.errorMsg);
                                    }
                                }, 2000);
                                setTimeout(function () {
                                    var indexs = parent.layer.getFrameIndex(window.name);//获取当前弹出层的层级
                                    parent.layer.close(indexs);//关闭弹出层
                                    //                        window.parent.location.reload();//刷新父页面
                                }, 4000);
                            }
                        })
                    }, 2000);
                });
                return false;
            });


        });
    }
</script>
</body>
</html>